<?php if (!defined('THINK_PATH')) exit();?><!doctype html>
<html>
<head>
	<meta charset="utf-8">
	<!-- Set render engine for 360 browser -->
	<meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">

    <!-- HTML5 shim for IE8 support of HTML5 elements -->
    <!--[if lt IE 9]>
      <script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
    <![endif]-->
	<link href="/public/simpleboot/themes/<?php echo C('SP_ADMIN_STYLE');?>/theme.min.css" rel="stylesheet">	
    <link href="/public/simpleboot/css/simplebootadmin.css" rel="stylesheet">
    <link href="/public/js/artDialog/skins/default.css" rel="stylesheet" />
    <link href="/public/simpleboot/font-awesome/4.4.0/css/font-awesome.min.css"  rel="stylesheet" type="text/css">
    <style>
		form .input-order{margin-bottom: 0px;padding:3px;width:40px;}
		.table-actions{margin-top: 5px; margin-bottom: 5px;padding:0px;}
		.table-list{margin-bottom: 0px;}
	</style>
	<!--[if IE 7]>
	<link rel="stylesheet" href="/public/simpleboot/font-awesome/4.4.0/css/font-awesome-ie7.min.css">
	<![endif]-->
	<script type="text/javascript">
	//全局变量
	var GV = {
	    ROOT: "/",
	    WEB_ROOT: "/",
	    JS_ROOT: "public/js/",
	    APP:'<?php echo (MODULE_NAME); ?>'/*当前应用名*/
	};
	</script>
    <script src="/public/js/jquery.js"></script>
    <script src="/public/js/wind.js"></script>
    <script src="/public/simpleboot/bootstrap/js/bootstrap.min.js"></script>
    <script>
    	$(function(){
    		$("[data-toggle='tooltip']").tooltip();
    	});
    </script>
<?php if(APP_DEBUG): ?><style>
		#think_page_trace_open{
			z-index:9999;
		}
        input[type=text]{
            height: 18px!important;
        }
        select{
            width: 160px;
        }
	</style><?php endif; ?>
</head>
<body>
	<div class="wrap">
		<ul class="nav nav-tabs">
			<li class="active"><a><?php echo L('USER_INDEXADMIN_INDEX');?></a></li>
			<!--<li><a href="<?php echo U('indexadmin/myuser');?>">我的客户</a></li>-->
			<li><a href="<?php echo U('indexadmin/add');?>">添加推广客户</a></li>
		</ul>
		<?php $group=get_groups_admin_user(); ?>
		<form class="well form-search" method="post" action="<?php echo U('Indexadmin/index');?>" style='line-height: 46px;'>
			手机号码： 
			<input type="text" name="mobile" style="width: 150px;" value="<?php echo I('request.mobile');?>" placeholder="请输入手机号码">
			姓名： 
			<input type="text" name="name" style="width: 150px;" value="<?php echo I('request.name');?>" placeholder="姓名">
			身份证：<input type="text" name="identity" style="width: 150px;" value="<?php echo I('request.identity');?>" placeholder="身份证">
			注册日期：<input class="js-date" type="text" name="starts" style="width: 150px;" value="<?php echo I('request.starts');?>" placeholder="起始时间">
			<input class="js-date" type="text" name="ends" style="width: 150px;" value="<?php echo I('request.ends');?>" placeholder="结束时间">
			<br />
			资料审核状态：<select name="type">
				<option value="">全部</option>
				<?php $tpl_selected=I('request.type')=='0'?"selected":""; ?>
				<option <?php echo ($tpl_selected); ?> value="0">待绑卡</option>
				<?php $tpl_selected=I('request.type')=='1'?"selected":""; ?>
				<option <?php echo ($tpl_selected); ?> value="1">上传证件照</option>
				<?php $tpl_selected=I('request.type')=='2'?"selected":""; ?>
				<option <?php echo ($tpl_selected); ?> value="2">待审核</option>
				<?php $tpl_selected=I('request.type')=='3'?"selected":""; ?>
				<option <?php echo ($tpl_selected); ?> value="3">学信认证</option>
				<?php $tpl_selected=I('request.type')=='4'?"selected":""; ?>
				<option <?php echo ($tpl_selected); ?> value="4">填写联系信息</option>
				<?php $tpl_selected=I('request.type')=='5'?"selected":""; ?>
				<option <?php echo ($tpl_selected); ?> value="5">信息填写完成</option>
				<?php $tpl_selected=I('request.type')=='8'?"selected":""; ?>
				<option <?php echo ($tpl_selected); ?> value="8">系统审核不通过</option>
			</select>
			借款状态：<select name="type_borr">
				<option value="">全部</option>
				<?php $tpl_selected=I('request.type_borr')=='0'?"selected":""; ?>
				<option <?php echo ($tpl_selected); ?> value="0">待申请借款</option>
				<?php $tpl_selected=I('request.type_borr')=='1'?"selected":""; ?>
				<option <?php echo ($tpl_selected); ?> value="1">待填写运营商信息</option>
				<?php $tpl_selected=I('request.type_borr')=='2'?"selected":""; ?>
				<option <?php echo ($tpl_selected); ?> value="2">借款中</option>
				<?php $tpl_selected=I('request.type_borr')=='3'?"selected":""; ?>
				<option <?php echo ($tpl_selected); ?> value="3">不通过</option>
			</select>
			当前订单状态：
			<select name="status">
				<option value="">全部</option>
				<option value="0">待审核</option>
				<option value="1">借款中</option>
				<option value="2">已还款</option>
				<option value="3">逾期</option>
				<option value="4">已到期</option>
				<option value="5">审核中</option>
				<option value="6">审核不通过</option>
				<option value="7">驳回</option>
				<option value="8">放款成功</option>
				<option value="9">放款不成功</option>
				<option value="10">待放款</option>
			</select>
			<script>
				$('select[name="status"]').find('option[value="<?php echo I('request.status');?>"]').prop('selected',true);
			</script>
			认领状态：<select name="byusers">
				<?php $tpl_selected=I('request.byusers')=='3'?"selected":""; ?>
				<option <?php echo ($tpl_selected); ?> value="3">全部</option>
				<?php $tpl_selected=I('request.byusers')=='1'?"selected":""; ?>
				<?php $tpl_selected=I('request.byusers')==''?"selected":$tpl_selected; ?>
				<option <?php echo ($tpl_selected); ?> value="1">未认领</option>
				<?php $tpl_selected=I('request.byusers')=='2'?"selected":""; ?>
				<option <?php echo ($tpl_selected); ?> value="2">已认领</option>
			</select>
			<br/>
			回流状态：<select name="reflux_status">
				<?php $tpl_selected=I('request.reflux_status')=='3'?"selected":""; ?>
				<?php $tpl_selected=I('request.reflux_status')==''?"selected":$tpl_selected; ?>
				<option <?php echo ($tpl_selected); ?> value="3">全部</option>
				<?php $tpl_selected=I('request.reflux_status')=='1'?"selected":""; ?>
				<option <?php echo ($tpl_selected); ?> value="1">正常用户</option>
				<?php $tpl_selected=I('request.reflux_status')=='2'?"selected":""; ?>
				<option <?php echo ($tpl_selected); ?> value="2">回流客户</option>
			</select>
			资料认证状态：
			<?php $ac_status_arr=array('-1'=>'全部','0'=>'未认证','1'=>'已认证','2'=>'认证未通过','3'=>'暂时不需要的','4'=>'除了已认证',); ?>
			<select name="account_status">
				<?php if(is_array($ac_status_arr)): foreach($ac_status_arr as $k=>$at): ?><option <?php if($account_status == $k): ?>selected<?php endif; ?> value="<?php echo ($k); ?>"><?php echo ($at); ?></option><?php endforeach; endif; ?>
			</select>
			
			分销状态：<select name="is_dis">
				<?php $tpl_selected=I('request.is_dis')=='3'?"selected":""; ?>
				<option <?php echo ($tpl_selected); ?> value="3">全部</option>
				<?php $tpl_selected=I('request.is_dis')=='2'?"selected":""; ?>
				<option <?php echo ($tpl_selected); ?> value="2">推广客户</option>
				<?php $tpl_selected=I('request.is_dis')=='1'?"selected":""; ?>
				<?php $tpl_selected=I('request.is_dis')==''?"selected":$tpl_selected; ?>
				<option <?php echo ($tpl_selected); ?> value="1">正常用户</option>
			</select>
			<input type="submit" class="btn btn-primary" value="搜索" />
			<a class="btn btn-danger" href="<?php echo U('Indexadmin/index');?>">清空</a>
			<br/>
			<button class="btn btn-primary js-ajax-submit" type="button" id='add_bate' data-action="<?php echo U('indexadmin/bate_add');?>" onclick='check(1)' >批量认领</button>
			<button class="btn btn-primary js-ajax-submit" type="button" id='add_bate2' data-action="<?php echo U('indexadmin/batch_add_reflux_user');?>" onclick='check(2)' >批量添加回流用户</button>
			<a class="btn btn-primary" id='export_btn' href="<?php echo U('indexadmin/export_app_user2',array('wheres'=>$wheres_str));?>" >导出</a>
			
			<?php if(($group == 1 || $group == 8 || $group == 10)): ?><button class="btn btn-primary js-ajax-trf" type="button" id='trf_bate' data-action="<?php echo U('indexadmin/transfer');?>" onclick='trf()' >转让</button><?php endif; ?>
			渠道来源：<input type="text" name="qudao" style="width: 150px;" value="<?php echo I('request.qudao');?>" placeholder="渠道来源">
		</form>
		<form method="post" class="js-ajax-form">
			<?php $model = new \User\Model\ReportCurrentOrders(); ?>
			<table class="table table-hover table-bordered" id='tab_check'>
				<thead>
					<tr>
						<th style='min-width: 30px;' align="center">选择</th>
						<th style='width: 66px;'><?php echo L('REGISTRATION_TIME');?></th>
						<th><?php echo L('NICENAME');?></th>
						<th style='min-width: 50px;'><?php echo L('IDENTITY');?></th>
						<th>芝麻分</th>
						<th style='min-width: 50px;'>手机</th>
						<th style='width: 35px;'>学历</th>
						<th>还款记录</th>
						<th style='min-width: 60px;'><?php echo L('USER_INFO');?></th>
						<th style='min-width: 50px;'><?php echo L('LOAN_INFO');?></th>
						<th style='min-width: 50px;'>当前<br />订单<br />状态</th>
						<th style='min-width: 50px;'>负责专员</th>
						<th style='min-width: 50px;'>资料认证状态</th>
						<th style='min-width: 50px;'>分销类型</th>
						<th style='min-width: 50px;'>审核失败原因</th>
						<th>渠道来源</th>
						<th>推荐码</th>
						<th>回流状态</th>
						<th>放款金额</th>
						<th  style='min-width: 50px;' align="center"><?php echo L('ACTIONS');?></th>
					</tr>
				</thead>
				<tbody>
					<?php $user_statuses=array("0"=>L('USER_STATUS_BLOCKED'),"1"=>L('USER_STATUS_ACTIVATED'),"2"=>L('USER_STATUS_UNVERIFIED')); ?>
					<?php if(is_array($list)): foreach($list as $key=>$vo): ?><tr>
						<td><input type='checkbox' name='id[]' value='<?php echo ($vo["id"]); ?>'/></td>
						<td><?php echo ($vo["crtime"]); ?></td>
						<?php if($group==3 || $group==8 || $group==10 || $group==6 || $group==13){ if($vo['account_status']==1){ $name=mb_substr($vo['name'],0,1,'utf-8').'**'; }else{ $name=$vo['name']; } }else{ $name=$vo['name']; } ?>
						<td><?php echo ((isset($name) && ($name !== ""))?($name):L('NOT_FILLED')); ?></td>
						<?php $iden=substr($vo['identity'],6,8) ?>
						<td><?php echo ($iden); ?></td>
						<td><?php echo ($vo['sesame_score']); ?></td>
						<td>
							<?php echo ($vo['photo_type']==1?'苹果':'安卓'); ?>
							<?php if($vo['photo_type']==1): ?><br/>【<?php echo ($vo['accept_bind']==0?'不接受':'接受'); ?>绑定】<?php endif; ?>
						</td>
						<td><?php echo ($vo["education"]); ?></td>
						<td>
							<?php if(empty($vo['borr_record'])): ?>无
								<?php else: ?>
								<?php echo ($vo['borr_record']); endif; ?>
						</td>
						<td>
							<?php if(($vo["type"] == 0)): ?>待绑卡
							<?php elseif($vo["type"] == 1): ?>上传证件照
							<?php elseif($vo["type"] == 2): ?>待审核
							<?php elseif($vo["type"] == 3): ?>学信认证
							<?php elseif($vo["type"] == 4): ?>填写联系信息
							<?php elseif($vo["type"] == 5): ?> 信息填写完成
							<?php elseif($vo["type"] == 8): ?>系统审核不通过<?php endif; ?></td>
						<td>
							<?php if(($vo["type_borr"] == 0)): ?>待申请借款
							<?php elseif($vo["type_borr"] == 1): ?>待填写运营商
							<?php elseif($vo["type_borr"] == 2): ?>借款中
							<?php elseif($vo["type_borr"] == 3): ?>审核不通过
							<?php elseif($vo["type_borr"] == 4): ?>已提额待激活<?php endif; ?>
						</td>
						<td>
							<?php echo $model->getStatusText($vo['status']); ?>
						</td>
						<!-- <td><?php echo ($vo["last_login_time"]); ?></td> -->
						<td><?php echo ($buyers[$vo['byusers']]); ?></td>
						<?php $ds=array('0'=>'<span style="color:red">未认证</span>','1'=>'<span style="color:green">已认证</span>','2'=>'<span style="color:red">认证未通过</span>','3'=>'<span style="color:red">暂时不需要</span>') ?>
						<!-- <td><?php echo ($ds[$vo['silver_stutas']]); ?></td> -->
						<td><?php echo ($ds[$vo['account_status']]); ?></td>
						<!-- <td><?php echo ($user_statuses[$vo['user_status']]); ?></td> -->
						<td><?php echo ($vo['is_dis']==1?'推广':'正常'); ?></td>
						<td><?php echo ($unapproved[$vo['unapproved']]); ?></td>
						<td><?php echo ((isset($codes[$vo['code']]) && ($codes[$vo['code']] !== ""))?($codes[$vo['code']]):''); ?></td>
						<td><?php echo ($is_dis[$vo['id']]); ?></td>
						<td>
							<?php switch($vo['reflux_status']): case "1": ?>正常<?php break;?>
								<?php case "2": ?>审核成功<?php break;?>
								<?php default: ?>回流用户<?php endswitch;?>
						</td>
						<td>
							<?php if(in_array((int)$vo['order_status'],[1,2,3,4,8])): echo ($vo['amount']); ?>
								<?php else: ?>
								0<?php endif; ?>
						</td>
						<td align="center">
							<?php if($send_sms[$vo['mobile']]): else: ?>
							<a class="js-ajax-dialog-btn" data-msg="确定 <?php echo ($vo['name']); ?> 发送初审 通过 短信通知?" href="<?php echo U('indexadmin/first_examine',array('user_id'=>$vo['id'],'type'=>1));?>">初审通知通过</a>
							<a class="js-ajax-dialog-btn" data-msg="确定 <?php echo ($vo['name']); ?> 发送初审 未通过 短信通知?" href="<?php echo U('indexadmin/first_examine',array('user_id'=>$vo['id'],'type'=>0));?>">初审通知失败</a>
							<br/><?php endif; ?>
							<?php if(($group == 14)): if($vo['account_status'] != 1): ?><a href="<?php echo U('indexadmin/see',array('id'=>$vo['id'],'from_type'=>1));?>">客户详情</a><?php endif; ?>
								|<a href="<?php echo U('indexadmin/info',array('id'=>$vo['id'],'dis'=>2));?>" ><?php echo L('MOD');?></a>
								<?php if(($vo["account_status"]) == "0"): if(($vo["silver_stutas"] == 0) or ($vo["silver_stutas"] == 2)): ?><!-- <br />|<a href="<?php echo U('indexadmin/examine',array('id'=>$vo['id']));?>">实名认证</a> --><?php endif; ?>
									<?php if(($vo["silver_stutas"] == 1)): endif; ?>
									<br />|<a href="<?php echo U('indexadmin/contact_exam',array('id'=>$vo['id']));?>">资料认证审核</a><?php endif; ?>
								<?php if(($vo["type"] == 8)): ?><br />|<a class="js-ajax-dialog-btn" data-msg="确定 <?php echo ($vo['name']); ?> 跳过系统认证?" href="<?php echo U('indexadmin/type_exam',array('id'=>$vo['id']));?>">跳过系统认证</a><?php endif; ?>
								<?php if(($vo["type"]) == "5"): if(($vo["type_borr"] == 1)): ?><br />|<a href="<?php echo U('indexadmin/jum_ban',array('id'=>$vo['id']));?>" class="js-ajax-dialog-btn" data-msg="确定 <?php echo ($vo['name']); ?> 跳过运营商验证?">跳过运营商验证</a><?php endif; ?>
									<?php if(($vo["type_borr"] == 2)): ?><br />|<a href="<?php echo U('indexadmin/jum_ban',array('id'=>$vo['id'],'type'=>1));?>" class="js-ajax-dialog-btn" data-msg="确定 <?php echo ($vo['name']); ?> 重新验证运营商?">重新验证运营商</a><?php endif; endif; ?>
							<?php else: ?>
								<?php if(($group == 13 || $group == 6)): if($vo['account_status'] != 1): ?><a href="<?php echo U('indexadmin/see',array('id'=>$vo['id'],'from_type'=>1));?>">客户详情</a><?php endif; ?>
								<?php else: ?>
									<a href="<?php echo U('indexadmin/see',array('id'=>$vo['id'],'from_type'=>1));?>">客户详情</a><?php endif; ?>
								|<a href="<?php echo U('indexadmin/info',array('id'=>$vo['id'],'dis'=>2));?>" ><?php echo L('MOD');?></a>
								<?php if(($vo["account_status"]) == "0"): if(($vo["silver_stutas"] == 0) or ($vo["silver_stutas"] == 2)): ?><!-- <br />|<a href="<?php echo U('indexadmin/examine',array('id'=>$vo['id']));?>">实名认证</a> --><?php endif; ?>
									<?php if(($vo["silver_stutas"] == 1)): endif; ?>
									<br />|<a href="<?php echo U('indexadmin/contact_exam',array('id'=>$vo['id']));?>">资料认证审核</a><?php endif; ?>
								<?php if(($vo["type"] == 8)): ?><br />|<a class="js-ajax-dialog-btn" data-msg="确定 <?php echo ($vo['name']); ?> 跳过系统认证?" href="<?php echo U('indexadmin/type_exam',array('id'=>$vo['id']));?>">跳过系统认证</a><?php endif; ?>
								<?php if(($vo["type"]) == "5"): if(($vo["type_borr"] == 1)): ?><br />|<a href="<?php echo U('indexadmin/jum_ban',array('id'=>$vo['id']));?>" class="js-ajax-dialog-btn" data-msg="确定 <?php echo ($vo['name']); ?> 跳过运营商验证?">跳过运营商验证</a><?php endif; ?>
									<?php if(($vo["type_borr"] == 2)): ?><br />|<a href="<?php echo U('indexadmin/jum_ban',array('id'=>$vo['id'],'type'=>1));?>" class="js-ajax-dialog-btn" data-msg="确定 <?php echo ($vo['name']); ?> 重新验证运营商?">重新验证运营商</a><?php endif; endif; endif; ?>
						</td>
					</tr><?php endforeach; endif; ?>
				</tbody>
			</table>
			<div class="pagination"><?php echo ($page); ?></div>
		</form>
	</div>
	<div id="dialog" style='display:none' >
	  <p>请选择转让的审核专员</p>
	  <ul style='width: 500px;list-style-type:none;'>
		<?php $i=0; ?>
		<?php if(is_array($shen_user)): foreach($shen_user as $key=>$vo): ?><li style='width: 110px;float: left;'><input type="radio" name='us_id' value='<?php echo ($vo["id"]); ?>' style='margin: 0 0 0 10px;'/><?php echo ($vo["user_login"]); ?></li>
		<?php $i++; ?>
		<?php if(($i == 4)): ?><br/>
		<?php $i=0; endif; endforeach; endif; ?>
	  </ul>
	</div>
	<script src="/public/js/common.js"></script>
	<script>
	function check(type){
        	var btn;
	    	if(1==type){
	    	    btn = $('button.js-ajax-submit').eq(0);
			}else if(2==type){
	    	    btn = $('button.js-ajax-submit').eq(1);
			}
			form = $('form.js-ajax-form');
			var obj=document.getElementsByName('id[]'); 
			var s=0; 
			for(var i=0; i<obj.length; i++){ 
				if(obj[i].checked) s+=1; 
			}
			if(s==0){
				alert('请选择客户');
				return ;
			}
			form.ajaxSubmit({
	                url: type ? btn.data('action') : form.attr('action'),
	                //按钮上是否自定义提交地址(多按钮情况)
	                dataType: 'json',
	                beforeSubmit: function (arr, $form, options) {
						var tx='批量添加';
	                    //按钮文案、状态修改
	                    btn.text(tx + '中...').attr('disabled', true).addClass('disabled');
	                },
	                success: function (data, statusText, xhr, $form) {
	                    //按钮文案、状态修改
	                    btn.removeClass('disabled').parent().find('span').remove();
	
	                    if (data.state === 'success') {
	                        $('<span class="tips_success">' + data.info + '</span>').appendTo(btn.parent()).fadeIn('slow').delay(1000).fadeOut(function () {
	                            if (data.referer) {
	                                //返回带跳转地址
	                                if (window.parent.art) {
	                                    //iframe弹出页
	                                    window.parent.location.href = data.referer;
	                                } else {
	                                    window.location.href = data.referer;
	                                }
	                            } else {
	                                if (window.parent.art) {
	                                    if(1==type){
	                                        reloadPage(window.parent);
										}else if(2==type){
	                                        window.location.reload();
										}
	                                } else {
	                                    //刷新当前页
	                                    reloadPage(window);
	                                }
	                            }
	                        });
	                    } else if (data.state === 'fail') {
	                        $('<span class="tips_error">' + data.info + '</span>').appendTo(btn.parent()).fadeIn('fast');
	                        btn.removeProp('disabled').removeClass('disabled');
	                    }
	                }
	            });
	}
	function trf(){
		var btn = $('#trf_bate');
		form = $('form.js-ajax-form');
		var obj=document.getElementsByName('id[]'); 
		var s=''; 
		for(var i=0; i<obj.length; i++){ 
			if(obj[i].checked){
				if(s==''){
					s=obj[i].value;
				}else{
					s+=','+obj[i].value;
				}
				
			}
		}
		if(s==''){
			alert('请选择客户');
			return ;
		}
		href = btn.data('action'),
		href = href ? href : $this.attr('href');
		Wind.use('artDialog', function () {
		//document.getElementById("dialog").style.display='block';
			 art.dialog({
				title: false,
				//icon: 'question',
				content: $("#dialog").html(),
				//content: '1111',
				follow: document.getElementById('trf_bate'),
				close: function () {
					return true;
				},
				ok: function () {
					var radio = document.getElementsByName("us_id"); 
					var us_id=0;
					for (i=0; i<radio.length; i++) {  
						if (radio[i].checked) {  
							us_id=radio[i].value;
						}  
					}
					if(us_id==0){
						alert('请选择审核专员');
						return false;
					}
					$.ajax({
							url:href,
							type:'post',
							dataType:'json',
							data:'users='+s+'&us_id='+us_id,
							success:function(map){
								if (map.state == 'success') {
											art.dialog({
											content: map.info,
											icon: 'success',
											ok: function () {
												this.title(map.info);
												return true;
											}
										});
								} else if (map.state == 'fail') {
									//art.dialog.alert(data.info);
									//alert(data.info);//暂时处理方案
									art.dialog({
										content: map.info,
										icon: 'warning',
										ok: function () {
											this.title(map.info);
											return true;
										}
									});
								}
							}
								
					}); 
				},
				cancelVal: '关闭',
				cancel: true
			});
		});
		
	}
	</script>
</body>
</html>